refactored to work with both map-based and client-based removal