refactor the API calls from controllers to services