Thats such a simpler way of doing it. Why didn't I think of that. %i is set somewhere else, but yes the second code could be altered in a similar manner without much bother.

Not to worry I'm probably going to recode the whole thing to use hash tables shortly anyway.