Work function sometimes starts again

Hi everybody,

I am writing a simple BPSK demodulator (decimation) block.
I’ve created decimator block by gr_modtool and now.
The problem is whenever I reach 4000 input samples work loop starts
again (I suppose that not only work loop, whole block as well).

for example:
decimation: 100

I used set_history(100), and in every work call i read in[(100*i)+50]
and compare with previous value, which I save in global variable,
because Ive tried everything. In this state outputs samplex 40 80 120
are fake…

Anybody knows how to fix it?

Regards