Fixed an array index bug