Need to remove Delay()

In the last part of program there are 40sec delay. I need to remove delay with same functions.

#include <Servo.h>  
#include <DHT.h> 
const int move_sensor = 2; 
const int button = 4;
const int motor1_IN3 = 5; 
const int motor2_IN4 = 6; 
const int LEDpin1 = 7; 
const int LEDpin2 = 8; 
const int motor_ENB = 9; 
const int DHTPIN = 11; 
const int LEDpin3 = 12; 
int state = LOW;
int reading;      
int previous = HIGH; 
#define DHTTYPE DHT11 
DHT dht(DHTPIN, DHTTYPE);
long time = 0; 
long debounce = 200; 

Servo servo1;

void setup()
{
  servo1.attach(3); 
  pinMode(A0, INPUT); 
  pinMode (2, INPUT);
  pinMode(4, INPUT); 
  pinMode(5, OUTPUT); 
  pinMode(6, OUTPUT); 
  pinMode (7, OUTPUT); 
  pinMode (8, OUTPUT); 
  pinMode (9, OUTPUT); 
  pinMode (12, OUTPUT); 
}

void loop()
{
/* Servo move by switcher */
{
    reading = digitalRead(4); 
   if (reading == HIGH && previous == LOW && millis() - time > debounce)
     {
       if (state == HIGH) 
        state = LOW;
       else 
        state = HIGH;
       time = millis();  
       }
    digitalWrite(8, state); 
   if (state == HIGH)
     {
        servo1.write(0);
     }
   else   
     {                    
        servo1.write(90);
     }
    previous = reading;
}

/* Light on, if it is dark */
{
   if (analogRead(A0) < 150) 
   {
      digitalWrite(12, HIGH);
   }
   else
   {
      digitalWrite(12, LOW); 
   }
}

/* If temperature more 27, then turn on motor */
{
   float t = dht.readTemperature();
   if (t > 27)
   {
      digitalWrite (6, HIGH); 
      digitalWrite (5, LOW);
      analogWrite(9,200);
   }
   else 
   {
      digitalWrite (6, LOW);
      digitalWrite (5, LOW);
   }
}
/* If smth move, then turn light on*/
{
   int move;       
    move = digitalRead (2);      
   if(move == HIGH)             
   {          
      digitalWrite (7, HIGH);
      delay (40000)
      digitalWrite (7, LOW);
   }
   else 
   {
      digitalWrite (7, LOW);
   }
}
}

Permission granted.

Have a look at Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.

Or additionally replace it with millis() as @UKHeliBob points out.