Fixed broken for loop