refactor the Detector class