cleaned up email functions