closer to actually working version
working version with modularized driving detector function