updated code as per suggestions by freeroby for marketing email api