Corrections: 

- the current patch crashes with 5 attachments
- my suggested code will also crash with 5 attachments