Fixed a bug in sheduler