refactor of mask process