Updated faulty solution for remembering cursor position.