FSM (was dysfunctional function)

Hard to say. I'm not at all clear what your system as a whole is doing.