Avoid iterate full word when the diagonal value is greater or equal to max_distance