updated for loop