Renamed a variable ("index") to avoid compile-time warning. (Thanks to Emmanuel Blot). Range check improved.