Refactor a code using the function nc.clonevar().