                     return e
                 }
             }
-            
-            return nil
-        }
-    }
-    
+            return nil
+        }
+    }
     
     /// get data set for highlight
     ///
     /// - Parameter highlight: current highlight
     /// - Returns: dataset related to highlight
     open func getDataSetByHighlight(_ highlight: Highlight) -> IChartDataSet!
-    {
-        let dataObjects = allData
-        
-        if highlight.dataIndex >= dataObjects.count
-        {
-            return nil
-        }
-        
-        let data = dataObjects[highlight.dataIndex]
+    {  
+        if highlight.dataIndex >= allData.count
+        {
+            return nil
+        }
+        
+        let data = dataByIndex(highlight.dataIndex)
         
         if highlight.dataSetIndex >= data.dataSetCount
         {

        super.notifyDataChanged() // recalculate everything
    }
    
    
    /// Get the Entry for a corresponding highlight object
    ///
    /// - parameter highlight:
    /// - returns: The entry that is highlighted
    open override func entryForHighlight(_ highlight: Highlight) -> ChartDataEntry?
    {
        let dataObjects = allData
        
        if highlight.dataIndex >= dataObjects.count
        {
            return nil
        }
        
        let data = dataObjects[highlight.dataIndex]
        
        if highlight.dataSetIndex >= data.dataSetCount
        {

        {
            return data.dataSets[highlight.dataSetIndex]
        }
    }
}
