refactored uniqueness validation and error messages