query is now paginating and sorting