optimizate the heap impl