fsm working. (not verified)