externalized statemachine