mail logic added