better template generation