added code for computing the edit distance