abstracted the API calls into a helper class. Moved more api calls to the server side.