Added the detect code