fixed bugs, improve validation performance