add caretSelection() function