move api call to controller