Corrected a bug in scheduler.