     
     ///For normal use of KatsanaSDK, this class is never called except when used for different purpose.
     public func cache(trip: Trip, vehicleId: String) {
+//        var travels = [Travel]()
+//        var dates = [Date]()
+//        var currentDate : Date!
+//        for trip in trips{
+//            if let date = currentDate{
+//                if !date.isEqualToDateIgnoringTime(trip.date) {
+//                    currentDate = trip.date
+//                    dates.append(currentDate)
+//                }
+//            }else{
+//                currentDate = trip.date
+//                dates.append(currentDate)
+//            }
+//        }
+//        
+//        for date in dates{
+//            let theTravel = travel(vehicleId: vehicleId, date: date)
+//            travels.append(theTravel)
+//        }
+        let classname = NSStringFromClass(Travel.self)
         var travel: Travel!
-        let classname = NSStringFromClass(Travel.self)
-        if let travelArray = data[classname] as? [[String: Any]]{
-            for travelDicto in travelArray {
-                if let theVehicleId = travelDicto["id"] as? String, vehicleId == theVehicleId, let travels = travelDicto["data"] as? [Travel] {
-                    for theTravel in travels {
+        var travelIndex: Int!
+        var theTravels : [Travel]!
+        var theUserIndex: Int!
+        var travelDicto = data[classname]
+        
+        if let travelDicto = travelDicto as? [[String: Any]]{
+            for (userIndex, dicto) in travelDicto.enumerated() {
+                if let theVehicleId = dicto["id"] as? String, vehicleId == theVehicleId, let travels = dicto["data"] as? [Travel] {
+                    theTravels = travels
+                    for (index, theTravel) in travels.enumerated() {
                         if let travelDate = theTravel.date, travelDate.isEqualToDateIgnoringTime(trip.date){
                             travel = theTravel
+                            travelIndex = index
+                            theUserIndex = userIndex
                         }
                     }
                 }

                    autoSave()
                }
                break
            }
        }
    }

        if let travel = travel{
            for aTrip in travel.trips {
                if aTrip.date == trip.date {
                    if trip.locations.count > aTrip.locations.count {
                        aTrip.locations = trip.locations
                    }
                    for (key, value) in trip.extraData{
                        aTrip.extraData[key] = value
                    }
                    haveSameTrip = true
                    break
                }
