                 let newBuffer: CVPixelBuffer? = self.renderContext.newPixelBuffer()
 
                 if let buffer = newBuffer{
-                    instruction.context.render(image, toCVPixelBuffer: buffer)
-                    request.finishWithComposedVideoFrame(buffer)
+                    instruction.context.render(image, to: buffer)
+                    request.finish(withComposedVideoFrame: buffer)
                 }
                 else{
-                    request.finishWithComposedVideoFrame(pixels)
+                    request.finish(withComposedVideoFrame: pixels)
                 }
             }
         }
     }
     
     func renderContextChanged(newRenderContext: AVVideoCompositionRenderContext){
-        dispatch_sync(self.renderContextQueue){
+        self.renderContextQueue.sync{
             self.renderContext = newRenderContext
         }
     }

                    return
                }
                
                var image = CIImage(CVPixelBuffer: pixels)
                for filter in instruction.filters{
                  filter.setValue(image, forKey: kCIInputImageKey)
                  image = filter.outputImage ?? image

   
    // You may alter the value of kCVPixelBufferPixelFormatTypeKey to fit your needs
    var requiredPixelBufferAttributesForRenderContext: [String : Any] = [
        kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32BGRA as UInt32),
        kCVPixelBufferOpenGLESCompatibilityKey as String : NSNumber(value: true),
        kCVPixelBufferOpenGLCompatibilityKey as String : NSNumber(value: true)
    ]
    
    // You may alter the value of kCVPixelBufferPixelFormatTypeKey to fit your needs
    var sourcePixelBufferAttributes: [String : Any]? = [
        kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32BGRA as UInt32),
        kCVPixelBufferOpenGLESCompatibilityKey as String : NSNumber(value: true),
        kCVPixelBufferOpenGLCompatibilityKey as String : NSNumber(value: true)
    ]
    
    let renderQueue = DispatchQueue(label: "com.jojodmo.videofilterexporter.renderingqueue", attributes: [])
    let renderContextQueue = DispatchQueue(label: "com.jojodmo.videofilterexporter.rendercontextqueue", attributes: [])
    
    var renderContext: AVVideoCompositionRenderContext!
    override init(){
        super.init()
    }
    
    func startVideoCompositionRequest(_ request: AVAsynchronousVideoCompositionRequest){
        autoreleasepool(){
            self.renderQueue.sync{
                guard let instruction = request.videoCompositionInstruction as? VideoFilterCompositionInstruction else{
                    request.finishWithError(NSError(domain: "jojodmo.com", code: 760, userInfo: nil))
                    return
