improvements on the fsm