improvements on fsm