defensive for loop