Scope logic fix