                 prevPrev = prev
                 prev = cur
                 cur = next
-                next = dataSet.entryForIndex(j + 1)
+                next = dataSet.entryForIndex(j + 1) ?? cur
                 
                 if next == nil { break }
                 

            let circleHoleRadius = circleHoleDiameter / 2.0
            let isDrawCircleHoleEnabled = dataSet.isDrawCircleHoleEnabled
            
            guard let
                entryFrom = dataSet.entryForXIndex(self.minX),
                entryTo = dataSet.entryForXIndex(self.maxX)
                else { continue }
            
            let diff = (entryFrom == entryTo) ? 1 : 0
            let minx = max(dataSet.entryIndex(entry: entryFrom) - diff, 0)
            let maxx = min(max(minx + 2, dataSet.entryIndex(entry: entryTo) + 1), entryCount)
            
            for (var j = minx, count = Int(ceil(CGFloat(maxx - minx) * phaseX + CGFloat(minx))); j < count; j++)
            {

        
        let entryCount = dataSet.entryCount
        
        var fromEnty: ChartDataEntry?
        var toEntry: ChartDataEntry?
        for x in (self.minX...self.maxX) {
            let entry = dataSet.entryForXIndex(x)
            if let e = entry {
                if fromEnty == nil {
                    fromEnty = e
                }
                toEntry = e
            } else if toEntry != nil {
                break
            }
        }
        
        guard let fromIndex = fromEnty.map({dataSet.entryIndex(entry: $0) }),
                toIndex = toEntry.map({dataSet.entryIndex(entry: $0) }) else { return }
        let diff = (fromIndex == toIndex) ? 1 : 0
        let minx = max(fromIndex - diff, 0)
        let maxx = min(max(minx + 2, toIndex + 1), entryCount)
        
        let phaseX = animator.phaseX
        let phaseY = animator.phaseY
