refactored validation part1
refactored validation part2