Improve caret.js