Correct array index error