update email validation; minor refactoring