reimplmentation of watchdog