optimized the scheduler for performance by replacing the linked list with a heap.