finished fsm example