changed FSM from an object literal to a function