fix Negative array index too large for array size 0