implementing #heapify