Refactored alert directive.