             } else {
                 s = lastE
                 e = CGPointMake(randomCGFloat(), randomCGFloat())
+                var dotProduct = (e.x - s.x) * (lastE.x - lastS.x) + (e.y - s.y) * (lastE.y - lastS.y)
+                var angle = acos(dotProduct / (lengthOf(s, e: e) * lengthOf(lastS, e: lastE)))
+                //change here to limit the range of angle 
+                while angle > 1.14 || angle < 1.04 {
+                    s = lastE
+                    e = CGPointMake(randomCGFloat(), randomCGFloat())
+                    dotProduct = (e.x - s.x) * (lastE.x - lastS.x) + (e.y - s.y) * (lastE.y - lastS.y)
+                    angle = acos(dotProduct / (lengthOf(s, e: e) * lengthOf(lastS, e: lastE)))
+                }
+                print(angle)
             }
             lastE = e
+            lastS = s
             let line : SKNode = drawLine(s, e:e).0;
             let ball1 = drawLine(s, e:e).1;
             let ball2 = drawLine(s, e:e).2;

    let resWidthRatio = CGFloat(0.8);
    let resHeightRatio = CGFloat(0.8);
    var gameSpeed = 20.0
    
    var balls = [(SKNode, SKNode)]()
    var lines : [SKNode] = [];

    
    func randomCGFloat() -> CGFloat {
        return CGFloat(Float(arc4random()) / Float(UINT32_MAX))
    }
    
    func lengthOf(s: CGPoint, e: CGPoint) -> CGFloat {
        let xDiff = e.x - s.x
        let yDiff = e.y - s.y
        return sqrt(xDiff * xDiff + yDiff * yDiff)
    }
    
    /**
