fix a invalid array access bug