Fixed validation logic.