edit distance
refactor the code