fixed bug in mail code