reworked template generator