Added pagination for query