add autostop functionality