integrated functionality from test into main app
added paging for query result