Simplify the validation logic proposed in 25f96b164498988439c38baf6ff4c57763464824