finished fsm control