Привет, ты, как эксперт с 20 летним опытом, помоги улучшить/оптимизировать логику следующего кода
```C#
    private StatusEvent? DetermineStatusEvent(
        BaseEvent baseEvent,
        EventMinimizationDowntime eventMinimizationDowntime,
        DateTime startTime,
        IEnumerable<StatusEvent> statusEvents,
        HistoryOfChangesEventMinimizationDowntime? minimizationDowntimeHistory = null)
    {
        // 1. Unchecked/DoesNotRequireControl + IsInstalledImportanceFactorTechnologicalPlace == true
        //    && нет истории + время прошло
        if ((baseEvent.StatusEvent?.SystemStatus is SystemStatus.Unchecked or SystemStatus.DoesNotRequireControl) &&
            eventMinimizationDowntime.IsInstalledImportanceFactorTechnologicalPlace &&
            minimizationDowntimeHistory?.IsInstalledImportanceFactorTechnologicalPlace == false)
        {
            var systemStatus = startTime < DateTime.UtcNow
                ? SystemStatus.New
                : SystemStatus.InProgress;

            return
                statusEvents.FirstOrDefault(x => x.IsStartingStatusForUploaded && x.SystemStatus == systemStatus);
        }

        // 2. InProgress + есть изменения
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.InProgress &&
            EventHasChanges(baseEvent, eventMinimizationDowntime, minimizationDowntimeHistory))
        {
            return
                statusEvents.FirstOrDefault(x => x.SystemStatus == SystemStatus.InProgress && x.IsNewDefect);
        }

        // 3. Completed + есть изменения
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.Completed &&
            EventHasChanges(baseEvent, eventMinimizationDowntime, minimizationDowntimeHistory))
        {
            return
                statusEvents.FirstOrDefault(x => x.SystemStatus == SystemStatus.Completed && x.IsNewDefect);
        }

        // 4. New + M1 + Start и End даты заполнены
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.New && baseEvent.ViewSourceEvent == ViewSourceEventTypes.M1 
            || baseEvent is
            { 
                StartDateTime: not null, 
                EndDateTime: not null
            }
            || eventMinimizationDowntime is
            {
                IsInstalledImportanceFactorTechnologicalPlace: false, 
                ReasonPlainId: not null
            })
        {
            return
                statusEvents.FirstOrDefault(x => x.SystemStatus == SystemStatus.DoesNotRequireControl);
        }

        // 5. New + M3 + MalfunctionStart и MalfunctionEnd даты заполнены
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.New && baseEvent.ViewSourceEvent == ViewSourceEventTypes.M3
            || baseEvent is
            {
                ViewSourceEvent: ViewSourceEventTypes.M3, StartDateTimeMalfunctionsForRcmn: not null,
                EndDateTimeMalfunctionsForRcmn: not null
            }
            || eventMinimizationDowntime.IsInstalledImportanceFactorTechnologicalPlace == false)
        {
            return statusEvents.FirstOrDefault(x => x.SystemStatus == SystemStatus.DoesNotRequireControl);
        }

        // 6. New + M1 + Start != null, End == null + время прошло
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.New && baseEvent.ViewSourceEvent == ViewSourceEventTypes.M1 
            || (baseEvent is { StartDateTime: not null, EndDateTime: null } &&
            startTime < DateTime.UtcNow)
            || eventMinimizationDowntime.IsInstalledImportanceFactorTechnologicalPlace
            || eventMinimizationDowntime is { IsInstalledImportanceFactorTechnologicalPlace: true, ReasonPlainId: null })
        {
            return statusEvents.FirstOrDefault(x =>
                x.IsStartingStatusForUploaded && x.SystemStatus == SystemStatus.InProgress);
        }

        // 7. New + M3 + MalfunctionStart != null, MalfunctionEnd == null + время прошло
        if (baseEvent.StatusEvent?.SystemStatus == SystemStatus.New &&
            baseEvent is
            {
                ViewSourceEvent: ViewSourceEventTypes.M3, 
                StartDateTimeMalfunctionsForRcmn: not null,
                EndDateTimeMalfunctionsForRcmn: null
            } 
            && startTime < DateTime.UtcNow)
        {
            return statusEvents.FirstOrDefault(x =>
                x.IsStartingStatusForUploaded && x.SystemStatus == SystemStatus.InProgress);
        }

        return null;
    }
```