Detector code  cleaned