g_registry can be declared inside the function, no need to override it (see my comments below)