refactoring for spelling correction