fix for compounding/cascading filters

'data' needs to be reset inside the 'flag' controlled loop or
*undefined* behavior is likely when user sets 'flag' and loop repeats
without resetting 'data' to beginning of block.
fix for bug I introduced with my last fix.

I left 'end' in an undefined state before.
put pointer assignment after test

I put the line I had moved into the loop the wrong side of the test
conditional.
Merge pull request #11 from robsoles/master

fix for compounding/cascading filters