Added more error handling for server failures