Fixed for loop in script