Using PriorityQueue instead