fix bug with lock in Scheduler class