Fix editDistance algorithm