Arduino Bluetooth Issue

I am connecting to my ardunio via a Bluetooth Bee (Actually , its a Seeedstudio 'bee') . Anyhow , I send a command to turn on/off an LED on pin 3 . The problem I am having is that it only seems to work 75% of the time. I can turn it on and off but sometimes I have to enter a/b several times , even if I am 1 foot away from the device. Could this be a hardware issue? Please let me know if any problems are obvious in my code , maybe a delay?

Thanks in advance!

#include <SoftwareSerial.h>   
#define RxD 12
#define TxD 13
#define DEBUG_ENABLED  1
SoftwareSerial blueToothSerial(RxD,TxD);

int ledpin1 = 3; 
 

 
 
void setup() 
{ 
      
    pinMode(ledpin1, OUTPUT);  
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    setupBlueToothConnection();
 
} 
 
void loop() 
{ 
  
 
  if(blueToothSerial.read() == 'a')
  {
    digitalWrite(ledpin1, HIGH);  
    blueToothSerial.println(" LED on pin one is now on");
  }
  if(blueToothSerial.read() == 'b')
  {
    digitalWrite(ledpin1, LOW);  
    blueToothSerial.println(" LED on pin one is now off");
    
}


 
} 
 
 
void setupBlueToothConnection()
{
    blueToothSerial.begin(38400); 
    delay(1000);
    sendBlueToothCommand("\r\n+STWMOD=0\r\n");
    sendBlueToothCommand("\r\n+STNA=TestMode\r\n");
    sendBlueToothCommand("\r\n+STAUTO=0\r\n");
    sendBlueToothCommand("\r\n+STOAUT=1\r\n");
    sendBlueToothCommand("\r\n +STPIN=0000\r\n");
    delay(2000); 
    sendBlueToothCommand("\r\n+INQ=1\r\n");
    delay(2000); 
}
 

void CheckOK()
{
  char a,b;
  while(1)
  {
    if(blueToothSerial.available())
    {
    a = blueToothSerial.read();
 
    if('O' == a)
    {
      
      while(blueToothSerial.available()) 
      {
         b = blueToothSerial.read();
         break;
      }
      if('K' == b)
      {
        break;
      }
    }
   }
  }
 
  while( (a = blueToothSerial.read()) != -1)
  {
    
  }
}
 
void sendBlueToothCommand(char command[])
{
    blueToothSerial.print(command);
    CheckOK();   
}
  if(blueToothSerial.read() == 'a')
  {
    digitalWrite(ledpin1, HIGH);  
    blueToothSerial.println(" LED on pin one is now on");
  }
  if(blueToothSerial.read() == 'b')
  {
    digitalWrite(ledpin1, LOW);  
    blueToothSerial.println(" LED on pin one is now off");
    
}

If the character in the buffer is a b, the first statement will read it, and decide that it is not an a. The next statement will read the next, possibly non-existant, character, and decide that it is not a b.

You need to test that there is a character to read first. Then, you need to read and store the character. Then, you need to test the stored character. Do NOT read every time.