Added edit distance calculation to the code.