cursor state logic