fix logic errors in Scheduler