Stacked 8 74HC595 flicker and output problem.

I'm now currently working on a project that has 64 bit output. Here's the code

char command;
String string,strval[8];
boolean ledon = false;

int val[8];
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11; 
  void setup()
  {
    pinMode(latchPin, OUTPUT);
    pinMode(dataPin, OUTPUT);  
    pinMode(clockPin, OUTPUT);
    Serial.begin(9600);
    Serial.println("begin");

    
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);
  }

  void loop()
  {
if (Serial.available() > 0) 
{string = "";}
    int k=0;
    while(Serial.available() > 0)
    {
      command = ((byte)Serial.read());
      //Serial.println(command);
      
      if(command == ';')
      {
        break;
      }
      
      else
      {
        string += command;
      }
      k=1;
      delay(3);
    }
       
int j=0;
if(k==1){

for(int i=0;i<8;i++){
  strval[i]="";
}
Serial.println(string);
for(int i=0;i<string.length();i++){
  char c=string[i];
    if(c=='|'){
       j++;}
    else {strval[j]+=c;} 
    }
  
for(int i=0;i<8;i++){
   val[i]=strval[i].toInt();
   Serial.println(val[i]);
}
}

digitalWrite(latchPin, LOW);

   // shift out the bits:
for(int i=7;i>=0;i--){  
 shiftOut(dataPin, clockPin,MSBFIRST, val[i]);
}
digitalWrite(latchPin, HIGH);

  }

The input is a string that has 8 decimals separated by the symbol "|" and marked by ";" for the prog to know it is the last character. I've tested this separation and putting the values into an array and it works fine.

Although when I combine this with the shiftout code, the output is different than expected. I've tried using the code, which basically is: latchpin on, shift the data, latch pin out, separately and it's fine. but when I use it one this. it doesn't work.

The setup and schematic i used is based on this https://www.arduino.cc/en/Tutorial/ShiftOut

I have 4 modules of this shiftout

one module is like this (from the same arduino page link) https://www.arduino.cc/en/uploads/Tutorial/ShftOut_Schm2.gif

I'm really stucked here. Thanks guys, I hope you can help.

First things first, don't use the the capacitor on ST_CP

Next do you have a decoupling capacitor ( .1uf ) close the each power pin on each I.C. ?

.