                 else
                 { // all others
                     
-                    for (var j = 0; j < clrs.count && j < entryCount; j++)
+                    for j in 0..<min(clrs.count, entryCount)
                     {
                         // if multiple colors are set for a DataSet, group them
                         if (j < clrs.count - 1 && j < entryCount - 1)

                }
            }
            
            for (var i = 0; i < labels.count; i++)
            {
                let drawingForm = colors[i] != nil
                var x = posX

            var colors = [UIColor?]()
            
            // loop for building up the colors and labels used in the legend
            for i in 0..<data.dataSetCount
            {
                let dataSet = data.getDataSetByIndex(i)!
                
