refactoring attachments