completed pagination for query