scheduling algorithm bug fix