reactive state machine