refactored pagination and API calls