added error handling for API client's method