updated edit distance code