edit the order of loop and condition