move api calls to seperate func