updated next state logic