                     }
                     
                     // read and write a tile sized portion of pixels from the input image to the output image.
-                    destContext.draw(sourceImageRef, in: destTile)
+                    destContext.draw(sourceTileImageRef!, in: destTile)
                 }
             }
             

    func decompress() -> UIImage {
        guard let imageRef = self.cgImage else { return self }
        
        let width = imageRef.width
        let height = imageRef.height
        
        if width == 0 || height == 0 { return self }
        
        let sourceTotalPixels = width * height
        let sourceTotalMB = CGFloat(sourceTotalPixels) / Constant.pixelsPerMB
        
        if sourceTotalMB > Constant.destImageSizeMB {
            return self.downsizing()
        } else {
            UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, self.scale)
            
            guard let context = UIGraphicsGetCurrentContext() else { return self }
            

                                              bitsPerComponent: 8,
                                              bytesPerRow: Int(bytesPerRow),
                                              space: CGColorSpaceCreateDeviceRGB(),
                                              bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)
                else { return self }
            
            // flip the output graphics context so that it aligns with the
