using minheap as priority queue