put loop back into template