updated validation code