updating for loop for mask validation