fixed a few bugs in validate