added and edited for loops