INTEROPERATION OF PUMP A AND B DURING FAILURE SCENARIOS

Problem statement:
pump A fills tank A and vice versa for B.
Both are connected to common sump.
during the failure of any selected pump the valve operates in a way to get water from another pump.
components used are UNO, 2 FLOW SENSORS, 3 SOLENOID VALVE, 8 CHANNEL RELAY, 2 MICRO SWITCH.
Help me with code. i attached my code. my proposed circuit is also attached.

flow_with_relay_on.ino (3.28 KB)

Help me with code. i attached my code. my proposed circuit is also attached.

What does the code do or not do that it should or shouldn't do ?

No circuit attached to the post