Added pagination for large queries