fixed rare state_to_command bug