Check if ag is aliased before unaliasing

Is there a more elegant check?