fixed template sub-generator logic