refactoring the mask check to be an expression.