wrong array index fixed