Check for `command.getFailureCount() > retryCountLimit || response.getStatusCode() != 500` here? Then we can skip the outermost `if` below and lose one level of indenting?