finish the new version of check_validity