fix bug of resetting cursor location