Fix bug in insert mode