Corrected mask implementation.