Refactor
Copy document function.