Fix issue that scopes with same name got overridden
use slightly clearer method