recreate FSM java