a simply light-weight general use of state_machine