Refine fix to PR10499, no functionality change

- Put expensive checking after simple one