'duration' does not name a type

'duration' does not name a type
I'm beginner and having this problem anyone know how to fix it? Much appreciated!

here's my code

const int trigPin=9;
const int echoPin=10;
int buzzer=11;

long duration;
int distance;

void setup(){
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}


void loop(){
  digitalWrite(trigPin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
}

duration=pulseIn(echoPin,HIGH);
distance=duration*0.034/2;

Serial.print("Distance:");
Serial.println(distance);

if(distance>10)
{
  Buzz();
}
}
void Buzz()
{
  digitalWrite(buzzer,HIGH);
  delay(500);
  digitalWrite(buzzer,LOW);
  delay(500);
  digitalWrite(buzzer,HIGH);
  delay(500);
  digitalWrite(buzzer,LOW);
  delay(500);
  digitalWrite(buzzer,HIGH);
  delay(500);
  digitalWrite(buzzer,LOW);
  delay(500);
}

Check your curly braces.
void loop() only has five lines. Then it ends with a curly brace.
The rest of the code is outside void loop().
Leo..