Lego motor shield on top of ethernet shield

I'm trying to turn a lego motor clockwise and counterclockwise by entering a website on my laptop. I put a lego motor shield on top of an ethernet shield, on top of my arduino uno. When I go to http://(my ip address)/$1, it turns clockwise, like it is supposed to. But when I go to http://(my ip address)/$2 after that, it is supposed to turn counterclockwise but instead it keeps on turning clockwise. Is there anything wrong with the code, or is something else wrong? Here is the code:

#include <Wire.h>
#include <Bricktronics.h>
#include <Motor.h>
Bricktronics brick = Bricktronics();
Motor m = Motor(&brick, 1);
#include <SPI.h>
#include <Ethernet.h>


boolean incoming = 0;

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(10,0,0,43); 
EthernetServer server(80);

void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
  Bricktronics brick = Bricktronics();
  brick.begin();
  m.begin();
}

void loop()
{
  EthernetClient client = server.available();
  if (client) {
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if(incoming && c == ' '){ 
          incoming = 0;
        }
        if(c == '

){
          incoming = 1;
        }
        if(incoming == 1){
          Serial.println(c);
         
          if(c == '1'){
            m.set_speed(100);
          }
          if(c == '2'){
            m.set_speed(-100);
          }
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
  }
}