Fix state_machine