fixed too long email validation and refactored the code a bit