reverting onDetect function