state machine
minor