not sure if setting the global var is needed here as the func is returning it anyway and not making use of the previous values (generally state changes of globals in functions should be avoided as that is not explicit)