Refactoring get variable name copy/paste

Implemented a more efficient way to get the variable names of the elements when copying and pasting.