insert mode refactoring