     }
     
     /// Remove the Service at the specified index.
-    public mutating func remove(service index: Int) {
-        
-        attributeGroups.remove(at: index)
+    public mutating func remove(service handle: UInt16) {
+        
+        guard let serviceIndex = attributeGroups.index(where: { $0.service.handle == handle })
+            else { fatalError("Service with handle \(handle) doesnt exist") }
+        
+        attributeGroups.remove(at: serviceIndex)
     }
     
     /// Write the value to attribute specified by the handle.

        
        attributeGroups.append(group)
        
        return attributeGroups.endIndex
    }
    
    /// Clear the database.

    
    // MARK: - Methods
    
    public mutating func add(service: Service) -> UInt16 {
        
        let serviceAttribute = Attribute(service: service, handle: newHandle())
        
