final version of alarm logic implemented