Placed batch saving into the for loop where it belongs