camera delay

Hello there!

im trying to make a automatic security burglar alarm.using a arduino yun, PIR, Led and a speaker. all the functions worked but there is this noticeable delay when i put my hand to the sensor. it takes up to 5 - 12 seconds delay before it triggers the camera and the led..
now i noticed that its because i programmed it to take pictures when there's no movement.

is there a solution for this? so that it would take a picture once movement is detected and then uploads it to my dropbox and momentarily take picture of the surrounding when there's no movement.

sorry for the bad english.
i'm a total newbie at programming.

here's my code:

#include<Bridge.h>


int ct = 10;
int pir = 6;
int led = 13;

long unsigned int lowIn;
long unsigned int pause = 5000;
boolean lockLow = true;
boolean takeLowTime;

Process p;


void setup() {
     // put your setup code here, to run once:
   Bridge.begin();
   Serial.begin(9600);
   pinMode(pir, INPUT);
   pinMode(led, OUTPUT);
   digitalWrite(pir, LOW);

   Serial.println("Please wait, calibrating the sensor for optimum output. . . .");
    for(int i = 0; i <= ct; i++){
      Serial.print(((i*100)/ct));
      Serial.print("%  ");
      Serial.println(" DONE.....");
      delay(1000);
    }
    Serial.println("Calibration Complete.");
    Serial.println(" ---SENSOR ACTIVE---");
    p.runShellCommand("madplay /mnt/sda1/mp3/audio.mp3"); //play the siren sound
      while(p.running()); //wait till the process ends
       delay(50); 
}
 
    


void loop() {
  // put your main code here, to run repeatedly:
   if(digitalRead(pir) == HIGH) {
    digitalWrite(led, HIGH);
  
    
    if(lockLow){
      lockLow = false;
    Serial.println("-----------------------");
    Serial.println(" ***MOTION DETECTED*** ");
    Serial.println("-----------------------");
    Serial.println("");
    Serial.println(millis()/1000);
    Serial.println("  sec");


    p.runShellCommand("fswebcam /mnt/sda1/pic.jpg" );
    while(p.running());
    p.runShellCommand("madplay /mnt/sda1/mp3/intruder_alert_2.mp3");
    while(p.running());
    p.runShellCommand("python /mnt/sda1/arduino1/upload-to-dropbox.py" );
    while(p.running());

    delay(30);
    
      
    }
   
    }
    if(!lockLow && millis() - lowIn > pause) {
      lockLow = true;
      Serial.print("Motion Ended at  ");
      Serial.print((millis()  - pause)/1000);
      Serial.println("  sec");
      delay(10);
      
    }
    else
    {
      digitalWrite(pir, LOW);
      digitalWrite(led, LOW);
      
      p.runShellCommandAsynchronously("fswebcam /mnt/sda1/pic.jpg"  );
      p.runShellCommand("python /mnt/sda1/arduino1/upload-to-dropbox.py"  );
      delay(600);
    }
   }