Adding a dynamic state machine