Bug fix in validation code