         if(canTakePhoto){
             HappieCameraJSON.incrementProcessingCount();
             canTakePhoto = false;
-            let connection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo)
-
-            stillImageOutput?.captureStillImageAsynchronously(from: connection) { imageBuffer, error in
+            let connection = stillImageOutput?.connection(with: AVMediaType.video)
+
+            stillImageOutput?.captureStillImageAsynchronously(from: connection!) { imageBuffer, error in
                 if((imageBuffer) != nil){
-                    let imageData: Data = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageBuffer)
+                    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  {

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

    }

    //MARK: Utility Functions
    func deviceWithMediaType(_ mediaType : AVMediaType, preferringPosition: AVCaptureDevice.Position) -> AVCaptureDevice{
        let devices : [AVCaptureDevice] = AVCaptureDevice.devices(for: mediaType)
        var captureDevice: AVCaptureDevice = devices.first as! AVCaptureDevice

        for device in devices{
            if((device as AnyObject).position == preferringPosition){
