Better opts checking for #18538
Merge pull request #18542 from techhat/issue18538

Better opts checking for #18538