Fixing copying function