minor issue fixed for loops