fix validation logic