fix the copy function