Reworked the api calls to make them DRY