refactored write view and attachments