first code for detection only