Fix problem when we are going out of array length boundary while doing heapify