The loop now takes place within the function