added timer safety function