Fix alerting logic