Tweak join code.

Hoist a conditional outside a loop.