factor out the has_attr checks