callTemplate function optimization.