FSM Implementation