fixed issue in heap_copy