minor chnages in for loop