         
         //TODO: handle the wrap condition
         let latitudeDelta = max(0.01, 1.3*(latitudeMax - latitudeMin))
-        let longitudeDelta = max(0.01, 1.3*(longitudeMax - longitudeMin))
-        
-        let averageLatitude = latitudeSum/CLLocationDegrees(articles.count)
-        let averageLongitude = longitudeSum/CLLocationDegrees(articles.count)
+        let longitudeDelta = max(0.01,1.3*(longitudeMax - longitudeMin))
+        
+        let averageLatitude = latitudeSum/CLLocationDegrees(coordinates.count)
+        let averageLongitude = longitudeSum/CLLocationDegrees(coordinates.count)
         
         let center = CLLocationCoordinate2D(latitude: averageLatitude, longitude: averageLongitude)
         let span = MKCoordinateSpanMake(latitudeDelta, longitudeDelta)

        var longitudeSum = CLLocationDegrees(0)
        var latitudeSum = CLLocationDegrees(0)
        
        for article in articles {
            guard let coordinate = article.coordinate else {
                continue
            }
            latitudeMin = min(latitudeMin, coordinate.latitude)
            longitudeMin = min(longitudeMin, coordinate.longitude)
            latitudeMax = max(latitudeMax, coordinate.latitude)

        }
    }
    
    func regionThatFits(articles: [WMFArticle]) -> MKCoordinateRegion {
        return regionThatFits(coordinates: articles.flatMap({ (article) -> CLLocationCoordinate2D? in
            return article.coordinate
        }))
    }
    
    func regionThatFits(coordinates: [CLLocationCoordinate2D]) -> MKCoordinateRegion {
        guard coordinates.count > 0 else {
            return MKCoordinateRegion()
        }
        var latitudeMin = CLLocationDegrees(90)
