refactor, and separate setMask selection and all scripts.