     }
     
     @IBAction func flashButtonPressed(sender: UIButton) {
+
+        if !cameraIsAvailable() {
+
+            return
+        }
 
         do {
 

    }
    
    @IBAction func flipButtonPressed(sender: UIButton) {
        
        session?.stopRunning()
        

            return
        }
    }

    func cameraIsAvailable() -> Bool {

        let status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)

        if status == AVAuthorizationStatus.Authorized {

            return true
        }

        return false
    }
}
