Extracted apply_attributes()