modified the validation code