Fixed broken copy function