model validation refactoring