replaces memcpy with copy