mistyped index in for loop