refactoring on datavalidation