completed heap implementation