compute edit distance