refactoring the validation stuff.