fixed alarm handler logic