fixing a bug with the validation code