added pagination for query results.