Moved API calls into a service