Simplifying logic in getAttachments