fix ordering issue with pagination