     @_versioned
     @inline(__always)
     func smapling2<ColorModel: ColorModelProtocol>(source: UnsafePointer<ColorPixel<ColorModel>>, width: Int, height: Int, point: Point, sampler: (Double, Double, Double) -> Double) -> ColorPixel<ColorModel> {
-        
-        let x_range = 0..<width
-        let y_range = 0..<height
         
         let _x1 = Int(point.x)
         let _y1 = Int(point.y)
         let _x2 = _x1 + 1
         let _y2 = _y1 + 1
-        let check1 = x_range.contains(_x1)
-        let check2 = x_range.contains(_x2)
-        let check3 = y_range.contains(_y1)
-        let check4 = y_range.contains(_y2)
         
         let _tx = point.x - Double(_x1)
         let _ty = point.y - Double(_y1)
         
-        if check1 || check2 || check3 || check4 {
-            
-            let __x1 = _x1.clamped(to: x_range)
-            let __x2 = _x2.clamped(to: x_range)
-            let __y1 = _y1.clamped(to: y_range)
-            let __y2 = _y2.clamped(to: y_range)
-            
-            let _s1 = check1 && check3 ? source[_y1 * width + _x1] : source[__y1 * width + __x1].with(opacity: 0)
-            let _s2 = check2 && check3 ? source[_y1 * width + _x2] : source[__y1 * width + __x2].with(opacity: 0)
-            let _s3 = check1 && check4 ? source[_y2 * width + _x1] : source[__y2 * width + __x1].with(opacity: 0)
-            let _s4 = check2 && check4 ? source[_y2 * width + _x2] : source[__y2 * width + __x2].with(opacity: 0)
-            
-            var color = ColorModel()
-            for i in 0..<ColorModel.count {
-                color.setComponent(i, sampler(_ty,sampler(_tx, _s1.color.component(i), _s2.color.component(i)), sampler(_tx, _s3.color.component(i), _s4.color.component(i))))
-            }
-            return ColorPixel<ColorModel>(color: color, opacity: sampler(_ty, sampler(_tx, _s1.opacity, _s2.opacity), sampler(_tx, _s3.opacity, _s4.opacity)))
-            
-        } else {
-            return ColorPixel<ColorModel>()
-        }
+        let _s1 = read_source(source, width, height, _x1, _y1)
+        let _s2 = read_source(source, width, height, _x2, _y1)
+        let _s3 = read_source(source, width, height, _x1, _y2)
+        let _s4 = read_source(source, width, height, _x2, _y2)
+        
+        var color = ColorModel()
+        
+        for i in 0..<ColorModel.count {
+            color.setComponent(i, sampler(_ty,sampler(_tx, _s1.color.component(i), _s2.color.component(i)), sampler(_tx, _s3.color.component(i), _s4.color.component(i))))
+        }
+        
+        return ColorPixel<ColorModel>(color: color, opacity: sampler(_ty, sampler(_tx, _s1.opacity, _s2.opacity), sampler(_tx, _s3.opacity, _s4.opacity)))
+        
     }
     
     @_versioned
     @inline(__always)
     func smapling4<ColorModel: ColorModelProtocol>(source: UnsafePointer<ColorPixel<ColorModel>>, width: Int, height: Int, point: Point, sampler: (Double, Double, Double, Double, Double) -> Double) -> ColorPixel<ColorModel> {
-        
-        let x_range = 0..<width
-        let y_range = 0..<height
         
         let _x2 = Int(point.x)
         let _y2 = Int(point.y)

        let min_y = _y - a + b
        let max_y = min_y + kernel_size
        
        let x_range = 0..<width
        let y_range = 0..<height
        
        for y in min_y..<max_y {
            for x in min_x..<max_x {
                let l = kernel((point - Point(x: x, y: y)).magnitude)
                let _source = x_range.contains(x) && y_range.contains(y) ? source[y * width + x] : source[y.clamped(to: y_range) * width + x.clamped(to: x_range)].with(opacity: 0)
                pixel += _source * l
                t += l
            }
        }
        return t == 0 ? ColorPixel<ColorModel>() : pixel / t

    
    @_versioned
    @inline(__always)
    func read_source<ColorModel: ColorModelProtocol>(_ source: UnsafePointer<ColorPixel<ColorModel>>, _ width: Int, _ height: Int, _ x: Int, _ y: Int) -> ColorPixel<ColorModel> {
        
        let x_range = 0..<width
        let y_range = 0..<height
        
        let check1 = x_range.contains(x)
        let check2 = y_range.contains(y)
        
        if check1 && check2 {
            return source[y * width + x]
        }
        
        let _x = x.clamped(to: x_range)
        let _y = y.clamped(to: y_range)
        
        return source[_y * width + _x].with(opacity: 0)
    }
    
    @_versioned
    @inline(__always)
    func convolve<ColorModel: ColorModelProtocol>(source: UnsafePointer<ColorPixel<ColorModel>>, width: Int, height: Int, point: Point, kernel_size: Int, kernel: (Double) -> Double) -> ColorPixel<ColorModel> {
        
        var pixel = ColorPixel<ColorModel>()
