refactor paste and copy