use $attachments array for all the attachments handling