Added missing scopes to function