using priority queue with our own comparator function