fixing copy function