Here is your code snippet Auto Formatted in the IDE to show the code blocks
if (gap > gapRangeL[4])
{
Serial.print("Gap > ");
Serial.println(gapRange[4]);
digitalWrite(speedpin1, LOW);
digitalWrite(speedpin2, LOW);
if (gap > gapRangeR[4])
{
Serial.print("Gap > ");
Serial.println(gapRange[4]);
digitalWrite(speedpin3, LOW);
digitalWrite(speedpin4, LOW);
Notice how much easier it is to see what is going on than your cramped, unformatted version