Refactor mask reader