adding logic to handle file attachments