Implementation of levenshtein algorithm