Added some additonal checks to make sure we don't hang or send empty emails