optimized a little the template renderer