                 if let object = section.object.base as? MessageSectionModel {
                     return
                         object.differenceIdentifier == message.identifier &&
-                            !message.isContentEqual(to: object.message)
+                        !message.isContentEqual(to: object.message)
                 }
 
                 return false
             })
 
             if let index = index {
-                var previous: AnyChatSection?
-
-                if index < data.count - 1 {
-                    previous = data[index + 1]
-                }
-
-                if let newSection = section(for: message.managedObject, previous: previous) {
+                if let newSection = section(for: message) {
                     data[index] = newSection
                 }
             } else {

    func fetchMessages(from oldestMessage: Date?) {
        guard !requestingData, hasMoreData else { return }
        guard let subscription = subscription?.validated() else { return }
        guard let subscriptionDetached = subscription.unmanaged else { return }

        let messages = subscription.fetchMessages(30, lastMessageDate: oldestMessage)
        for message in messages {
            if let section = section(for: message) {
                data.append(section)
            }
        }

        if messages.count > 0 {
            cacheDataSorted()
            onDataChanged?()
        }

        requestingData = true
        MessageManager.getHistory(subscriptionDetached, lastMessageDate: oldestMessage) { [weak self] oldest in
            DispatchQueue.main.async {
                self?.requestingData = false
                self?.hasMoreData = oldest != nil

        for insertion in insertions {
            guard
                insertion < messagesQuery.count,
                let message = messagesQuery[insertion].validated()?.unmanaged
            else {
                continue
            }
