added refactor alarm func