Still using a pair for the priority queue