changed invalid index

output array