Added detector code, not tested, compiles fine