MSSQL Pagination and Batching

I have a workflow which has a MSSQL query node which has a similar query

SELECT
  *
FROM Filiacion.dbo.Expediente a
WHERE a.NhcDefinitivo IS NOT NULL
ORDER BY a.IdExpediente
OFFSET {{ $('Initialize Variables').item.json.offset }} ROWS
FETCH NEXT {{ $('Initialize Variables').item.json.batchSize }} ROWS ONLY

I previously have the Initialized Variables for the offset =0 and batchSize=1000, it continues and gets my records, I continue with an if node where I check if I have data, when true it continues to a loop when I process the data, when the batched data finishes looping I should be able to update the offset, get the next batch and do the loop process again. I seem to be having issues updating the offset, as well as looping again the new batch. Can someone give me an idea of what I am doing wrong?