better validation with fewer code