fixed bugs in schedule generation