applied template for heap