Adding limits and paging to query