Fix for enabling alarm
Refactoring alarm code