bug fix for batch index off by 1