Run totallyGuarded() once outside of loop.

The boolean returned by totallyGuarded() will never change during the loop. Running the method outside of the foreach avoids one unnecessary count() and two checks for each iteration.