Updates caret position code