copy function implements