improve N matching