Implement states in your code using a state machine definition and multiple instances of the state machine.