I would get the root alias outside the foreach loop to avoid doing it several times