Index out of range fix by gboudreau.

It is your fix, so the credit is all yours. :)