refactored and moved api calls to application controller