 
             logger.debug("distinct network types: \(distinctNetworkTypes)")
             logger.debug("distinct models: \(distinctModels)")
+            
+            logger.debug("COUNT1: \(realm.objects(StoredHistoryItem.self).filter("model IN %@", distinctModels).count)")
+            logger.debug("COUNT2: \(realm.objects(StoredHistoryItem.self).filter("model IN %@", [distinctModels.first!]).count)")
+            logger.debug("COUNT3: \(realm.objects(StoredHistoryItem.self).filter("model IN %@", [distinctModels.last!]).count)")
         }
     }
     

        ]
    }

    
    ///
    public func getHistoryList(success: (response: [HistoryItem]) -> (), error failure: ErrorCallback) {
        if !dirty { // return cached elements if not dirty
            // load items to view
            if let historyItems = self.getHistoryItems() {
                success(response: historyItems)
            } else {
                failure(error: NSError(domain: "didnt get history items", code: -12351223, userInfo: nil)) // TODO: call error callback if there were realm problems

            ControlServer.sharedControlServer.getMeasurementHistory({ historyItems in
                self.insertOrUpdateHistoryItems(historyItems)

                if let dbHistoryItems = self.getHistoryItems(filters) {
                    success(response: dbHistoryItems)
                } else {
                    success(response: historyItems)
                }
                
            }, error: failure)
        }
    }

    ///
