Factor out attributes logic