reduce loop judge to advance performance