fixed wrong array index