refactored validation into a model