Added conditional logic for optional attachment files