correct solution to the Levenshtein distance problem