fix bug with templates