Building the heap