minor bug fix for a for loop