updated loops for batch runs