Perhaps you are missing the conjugate? One of those times should be “backward”. You also can make it so you don’t have to apply S^z_j twice, but instead measure \langle A|S^z_j|B\rangle so you can obtain all values quickly
There are number of tricks one has to do as well I believe, like linear prediction in [0901.2342] Spectral functions in one-dimensional quantum systems at T>0
See also Artifacts in Dynamical structure factor plots - #2 by miles