fixed a null pointer issue with attachments