added more http error handling