implemented a threshold autodetection