fixed an array index error