query with paging working