added control before the extraction of attachments