Simplify edit distance solution