better error handling for requests