fix wrong array index