Update template.cc
major bug fixed