fixing caret position