             var beaconsId: [String] = []
             beaconsId = fromArray
             if beaconsId.contains(deviceId) {
-                if let index = beaconsId.index(of: deviceId) {
-                    beaconsId.remove(at: index)
-                }
+                guard let index = beaconsId.index(of: deviceId) else {
+                        return
+                    }
+                beaconsId.remove(at: index)
             }
             return beaconsId
         }

        func clean(trigger: [String: ProximityEvent]) -> [String: ProximityEvent] {
            var t = trigger
            for (id, proximityEvent) in t {
                if let createdAt = proximityEvent.createdAt {
                    let now = Int64(Date().timeIntervalSince1970 * 1000)
                    let gap = now - createdAt
                    // If gap is higher than 5 minutes we will clear the value in the trigger dictionary
                    if gap > 5 * 60 * 1000 {
                        t.removeValue(forKey: id)
                    }
                }
            }
            return t

                    let proximityEvent = ProximityEvent.init(deviceId: id, distance: distance)
                    let deviceId = "NEED CHANGE to a guard"
                        sendProximityEvent(deviceId: deviceId, proximityEvent: proximityEvent) {(_ proximityEvent) in
                            guard let pe = proximityEvent else {
                                return
                            }
                            self.addProximityEvent(deviceId: id, proximityEvent: pe, clProximity: clProximity)
                    }
                } else {
                    //this id is already triggered and might need to be refresh -> refreshTriggers()
