Fix buildMaxHeap method