beginning of attachments' handling