reworked alarm manager code