added extra email validation and refactored