fixing bugs for template