Loop function

Did you do it like this: