fixed bug in validate function