added more error checking of template files