Revised validation to be more flexible