program detect function