fixing error handling of template fetch