Refactored request failure handling logic to only make one request