refactored email_library