refactoring cmd_fsm