fix mask iteration