handle empty templates better