improvements on templates