fixed bug with validation code