improved query behavior, now has total count when paging