add minor logic for mask switching