Use a state machine function to handle country selections.