detection written in C