improve circuit breaker logic