You can call `set` on this and `preferred_formats` right here instead of multiple times in the loop below.