It just looks overly convoluted. It would help to see what's going on if you used meaningful variable names. I thought the approach I was getting at in post 8 was substantially simpler.