Move condition earlier to avoid useless computations