CRUISE: Reduce the scope of variables used in the for loops