             }
         } else {
             for i in fromIndex.advanced(by: 1)...toIndex {
+                indices.append(i)
                 let formulaElement = elements[i]
                 let newSequence = i - 1
                 self.updateSequence(formulaElement, sequence: newSequence)

    }
    
    /// Adjusts the sequencing of elements affected by a move operation.
    mutating func moveProcedureElement(_ element: ProcedureElement, fromIndex: Int, toIndex: Int) {
        guard fromIndex != toIndex else {
            return
        }
        
        let elements = self.procedure
        
        if toIndex < fromIndex {
            for i in toIndex..<fromIndex {
                let e = elements[i]
                let newSequence = i + 1
                self.updateSequence(e, sequence: newSequence)
            }
        } else {
            for i in fromIndex.advanced(by: 1)...toIndex {
                let e = elements[i]
                let newSequence = i - 1
                self.updateSequence(e, sequence: newSequence)

    }
    
    /// Adjusts the sequencing of elements affected by a move operation.
    ///
    /// - returns: A range of indices that have been affected by this operation
    @discardableResult
    mutating func moveFormulaElement(_ element: FormulaElement, fromIndex: Int, toIndex: Int) -> [Int] {
        var indices: [Int] = []
        
        guard fromIndex != toIndex else {
            return indices
        }
        
        let elements = self.formula
        
        if toIndex < fromIndex {
            for i in toIndex..<fromIndex {
                indices.append(i)
                let formulaElement = elements[i]
                let newSequence = i + 1
                
