refactored levenshtein