modify the 2nd loop