move template rendering to separate class