refactoring validator