fix generating second level id in attachments