Move condition out of scope to avoid useless function call