added max_alerts check before creating new alert record