Added code to build the heap