finished function. Need to reduce API calls