Should work in or out of the loop

View the code