fixed work with templates