Using array functions instead of foreach to map attachments to ID keys