added template parsing