consolidated to 1 for loop