Xorik filter

Here's my proposal for rearranging the logic in the loop.  Please test to make sure it works.