Refactored to encapsulate use of PriorityQueue