Refactored the validation code to check whether there are duplicates or not.
Fixed a critical bug that prevented a password reset email from being sent.