fix paging with query APIs