modified copySelectedLayers.js