Code for the presence detectors