add @inbounds statement for heaps