Refactor character insertion