copy2 rewritten