Ahhah!

I came back and took a second look at this, and it all makes sense now. I see why it doesn't break and what it's trying to do. The double-nested loop hurt my brain. :(