fsm for controller