rewrite heapify