Batch loop fix