modified for loop