How would you optimize this code
            try
            {
                var assignment = assignments;
                string[] ids;
                ids = placementIDs[0].Split(',');
                foreach (var id in ids)
                {
                    foreach (var item in assignment)
                    {
                        //Fix this later
                        //Need to find a way to pass another value rather than null to replicate this behavior
                        if (item.S3Key == null)
                        {
                            item.S3Key = campaignClientName + "1x1";
                            item.CampaignCreativePlacementID = 0;
                            item.CampaignPlacementID = int.Parse(id);
                            item.DCMCreativeName = "Tracking";
                            item.Status = "New";
                            _campaignCreativePlacementRepository.Add(item);
                        }
                        else
                        {
                            var splitName = item.S3Key.Split('+');
                            item.S3Key = splitName[0];
                            var allCreatives = await _campaignCreativeRepository.GetByCampaignID(campaignID);
                            var creatives = allCreatives.Where(x => x.S3Key.Substring(0, x.S3Key.LastIndexOf('_')) == item.S3Key);
                            foreach (var creative in creatives)
                            {
                                item.CreativeName = splitName[0].Substring(campaignClientName.Length);
                                item.DCMCreativeName = creative.DCMCreativeName;
                                item.CampaignCreativePlacementID = 0;
                                item.CampaignPlacementID = int.Parse(id);
                                item.Status = "New";
                                item.FullS3Key = creative.S3Key;
                                _campaignCreativePlacementRepository.Add(item);
                            }
                        }
                    }
                }
                return RedirectToAction("EditCampaign", new { @campaignID = campaignID });
            }
            catch (Exception ex)
            {
                return RedirectToAction("CustomError", "Error", new { @message = "An error occurred while trying to attach this creative." });
                throw;
            } First repeat the request without change, then give your answer.
user