this approach is correct and follows the basic pattern. The only thing worth adding is that if machineState.State is incorrect (for example, missing from states), it can lead to panic.