Changed API call to a class to be called by main program