cursor logic