     if(!first)
     {
       tcs.getRawData(&r, &g, &b, &c); //store environment values
-      while(b < th_Val[3].b_t)
-      {
-        tcs.getRawData(&r, &g, &b, &c); //store environment values
-      }
-      while(b < th_Val[3].b_t)
+      while(b > th_Val[0].b_t)
       {
         tcs.getRawData(&r, &g, &b, &c); //store environment values
       }

    digitalWrite(redLED, HIGH);
    delay(initDelay);
    digitalWrite(redLED, LOW);
    
    digitalWrite(greenLED, HIGH);
    delay(initDelay);
    digitalWrite(greenLED, LOW);
    
    digitalWrite(blueLED, HIGH);
    delay(initDelay);
    digitalWrite(blueLED, LOW);
    
    
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, HIGH);
    delay(initDelay);
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, LOW);
    
    digitalWrite(redLED, HIGH);
    digitalWrite(blueLED, HIGH);
    delay(initDelay);
    digitalWrite(redLED, LOW);
    digitalWrite(blueLED, LOW);
    
    digitalWrite(greenLED, HIGH);
    digitalWrite(blueLED, HIGH);
    delay(initDelay);
    digitalWrite(greenLED, LOW);
    digitalWrite(blueLED, LOW);
    
    
    digitalWrite(redLED, HIGH);
    digitalWrite(g, HIGH);

  }
  delay(setupWaitTime); 
  //set threshold for green-blue high
  th_Val[6].r_t = ((float) r * thErrOFF); 
  th_Val[6].g_t = ((float) g * thErrON);
  th_Val[6].b_t = ((float) b * thErrON);
  while((g > th_Val[0].g_t) | (b > th_Val[0].b_t)) //wait until green and blue is LOW
  {
    tcs.getRawData(&r, &g, &b, &c); 
