update gidd by vichet - fix loop & allow template override