bug fix in template parsing