refactor for API requests