Use each instead of collect

each is enough for this case
Rename format to format_attributes