How can you tell that it is doing this?
Just to be sure, you add, for example,
Serial.print("p2 ");
in front of
Serial.println(digitalRead(2));
and similarly for the other pins.
What is "complex" about it? If it involves more delays and/or turning interrupts on and off, it could make a mess of...