replace try/except with `if 'class' in attrs:`