fixed race condition in TimeScheduler