This seems overly complex and there are some errors. It seems that the masks should go: F8, 7C, 3E, 1F Also, there's two tests for (i % 5) == 3 Instead of changing the mask, why not shift the byte under test and 'or' in the necessary bits from a look ahead byte (which is 0 if at the end of the array). It's a bit complicated (no pun intended) because you have to figure out when to get the next byte, but you should be able to do the whole thing in a loop. Marc MyXaml Advanced Unit Testing YAPO