Added state machine