writing heapify