added new code for templates