update edit distance