fixed bugs in scheduler