refactoring
improved the validation