initial heap version (copied from my C version heap)