Remove extra local variable in getCursorPosition