state machine controller