Updated template generation