tuned up template.c