Fixing array index warning