Fix the bug of mismatch calculation.