done with heaps