speed up levenshtein distance

This speeds up levenshtein distance calculation by about 1.6x