move alerting into a directive