Fixing wrong reference (local instead of global ref)