Improved Levenshtein distance