FSM Refactor