Fixed index error in template.php