copy helper refactoring.\ncopy helper can change contents, source, destination and encoding using a process function