go to post Michael Cronin · Dec 21, 2022 InitializeXMLParse does a lot of necessary things including the following: Calls Rewind() on its stream property Uses XSL "OrderSDAElements" or "OrderSDAElementsEdge" to sort the SDA objects in the container. Replace the stream property on HS.SDA3.Container with the sorted one Call Rewind() again and initialize a StreamPos property to 1 // This is used by FillBuffer() Initialize the ..StreamBuffer with the first 3600000 bytes of the stream This is a lot of overhead. Also, "do oSDA.StreamOref.Rewind()" and "oSDA.StreamPos = 1" fails to re-initialize the ..StreamBuffer.My suggestion would be to declare a MultiDimensional property in your class:Property %sdaclass [ MultiDimensional, Private ];Then follwing any call to GetNextSDA, save the SDA class in the MultiDimensional:set ..%sdaclass($increment(%sdaclass))=tPatient // replace tPatient with variable returned by GetNextSDA Your second pass can simply iterate over the MultiDimensional:set subscript=""for { set subscript=$order(..%sdaclass(subscript)) quit:subscript="" set sdaclass=..%sdaclass(subscript) ... processing logic B}