Refactoring to move api call and mapping out of controller