first working version of heapSort