adds better error handling, adds config options for API calls