Re-write of the FSM