improved email handling