FSM by Guillaume Febvrel