Fixed a bug in validation logic.