fix scopes and res factory