Manipulating the $query object