fixing validation code