set state and change the state.