Main alarm logic added