How to improve the performance of the scheduler program