more refactoring. fix email validation