Fixed invalid array access