Still don't entirely understand why you're using `global`. I prefer returning a value and then having the caller set the variable to that value. Makes it much easier to test/reason about independently.