[glance] faster and cleaner

The check has been rewrited to be faster and cleaner.