changed for loop index name to avoid variable clashes with other scripts