trying to fix logic in the attachment handling