refactor validatin