 
         previewLayer?.frame = CGRect(x: 0, y: 0, width: width,height: height)
         previewLayer?.bounds = CGRect(x: 0, y: 0,width: width,height: height)
-        previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill;
+        previewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill;
         
-        previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue)!;
+        previewLayer?.connection?.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue)!;
         camPreview.layer.addSublayer(previewLayer!)
 
         captureSession.startRunning()

        if(canTakePhoto){
            HappieCameraJSON.incrementProcessingCount();
            canTakePhoto = false;
            let connection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo)

            stillImageOutput?.captureStillImageAsynchronously(from: connection) { imageBuffer, error in
                if((imageBuffer) != nil){
                    let imageData: Data = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageBuffer)
                    let UIImageFromData = UIImage(data: imageData)

                    var  orient = UIImageOrientation.right;

@objc protocol cameraDelegate{ func cameraFinished(_ controller: HappieCameraViewController) }

@objc(HappieCameraViewController) class HappieCameraViewController : UIViewController, AVCaptureFileOutputRecordingDelegate  {
    func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {

    }


    //MARK: Class Variables
    let captureSession = AVCaptureSession() //provides a UI context for capturing media
