Improved time management using a priority queue