Fixed bug in template.php