         if let existingNode = map[node.value.key] {
             remove(node: existingNode)
         }
-        
         list.append(node)
         map[node.value.key] = node
         totalCost += node.value.cost

            lock.lock()  // faster than `sync()`
            defer { lock.unlock() }

            return map[key].map {
                // bubble node up to the head
                list.remove($0)
                list.append($0)
                return $0.value.image
            }
        }
        set {
            lock.lock() // faster than `sync()`

                add(node: Node(value: CachedImage(image: image, cost: cost(image), key: key)))
                trim()
            } else {
                guard let node = map[key] else { return }
                remove(node: node)
            }
        }
    }
