finish edit distance