changed delay() to wait for Serial.available()