reduce number of times caretPosition() is called