better code for heap example