add state machine from scratch