validation refactoring