         let offsetX: CGFloat = sqrt(pow(arcRadius, 2) - pow((closestHorizontalDistanceToEdge - (marginX + buttonRadius)), 2))
         let offsetY: CGFloat = sqrt(pow(arcRadius, 2) - pow((closestVerticalDistanceToEdge - (marginY + buttonRadius)), 2))
         
-        if (closestHorizontalDistanceToEdge == touchPointInset.left) {
-            
-        }
-        
-        var fromPoint: CGPoint = CGPoint(x: point.x + fromPointOffsetXSign * offsetX, y: fromPointOffsetYSign * (marginY + buttonRadius))
-        var toPoint: CGPoint = CGPoint(x:toPointOffsetXSign * (marginX + buttonRadius), y: point.y + toPointOffsetYSign * offsetY)
+        let baseFromPointX = point.x;
+        let baseFromPointY = touchPointPosition == .topLeft || touchPointPosition == .topRight ? 0.0 : size.height;
+        let baseToPointX = touchPointPosition == .topLeft || touchPointPosition == .bottomLeft ? 0.0 : size.width;
+        let baseToPointY = point.y;
+        
+        let fromPoint: CGPoint = CGPoint(x: baseFromPointX + fromPointOffsetXSign * offsetX, y: baseFromPointY + (marginY + buttonRadius) * fromPointOffsetYSign)
+        let toPoint: CGPoint = CGPoint(x:baseToPointX + (marginX + buttonRadius) * toPointOffsetXSign, y: baseToPointY + toPointOffsetYSign * offsetY)
         
         return [fromPoint, toPoint]
-        
     }
     
     private func distanceOfTouchPointToEdges(touchPoint point: CGPoint, inViewWithSize size: CGSize) -> UIEdgeInsets {
+        
         var edgeInsets : UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
         
         edgeInsets.top = point.y
-        edgeInsets.bottom = size.height - 0
+        edgeInsets.bottom = size.height - edgeInsets.top
         edgeInsets.left = point.x
         edgeInsets.right = size.width - point.x
         

        switch touchPointPosition {
        case .topLeft:
            fromPointOffsetXSign = touchPointInset.top >= arcRadius ? -1 : 1
            fromPointOffsetYSign = marginY + buttonRadius >= touchPointInset.top ? 1 : -1
            toPointOffsetXSign = marginX + buttonRadius >= touchPointInset.left ? 1 : -1
            toPointOffsetYSign = 1
            
        case .topRight:
            fromPointOffsetXSign = touchPointInset.top >= arcRadius ? -1 : 1
            fromPointOffsetYSign = marginY + buttonRadius >= touchPointInset.top  ? 1 : -1
            toPointOffsetXSign = marginX + buttonRadius >= touchPointInset.right ? -1 : 1
            toPointOffsetYSign = 1
            
        case .bottomLeft:
            fromPointOffsetXSign = touchPointInset.bottom >= arcRadius ? -1 : 1
            fromPointOffsetYSign = marginY + buttonRadius >= touchPointInset.bottom ? -1 : 1
            toPointOffsetXSign = marginX + buttonRadius >= touchPointInset.left ? 1 : -1
            toPointOffsetYSign = -1
            
        case .bottomRight:
            fromPointOffsetXSign = touchPointInset.bottom >= arcRadius ? -1 : 1
            fromPointOffsetYSign = marginY + buttonRadius >= touchPointInset.bottom ? -1 : 1
            toPointOffsetXSign = marginX + buttonRadius >= touchPointInset.right ? -1 : 1
            toPointOffsetYSign = -1
            
        default:

    var positioningType: ButtonPositionDriverType
    
    /// Arc
    var buttonsArc: Double = Double.pi / 2 + Double.pi / 6
    
    /// Distance from touchPoint to a button
    var distance: CGFloat = 100.0
    
    /// Allow the buttons and the distance from touchPoint to the button center to be scaled
    var scaleable: Bool = false
    
    /// Margin to the edge to the screen or the defined view
    var margin: CGFloat = 8.0
    
    /// If not provide maxButtonsAngle, maxButtonsAngle will be automatically calculated by numberOfButtons, maxButtonsAngle = Pi/(numberOfButtons * 2)
    init(numberOfButtons: Int, buttonRadius radius: CGFloat, buttonsAngle angle: Double = Double.pi/6, positioningType type: ButtonPositionDriverType = .Arc) {
