proper template parsing