use get instead of remove to preserve the same instance of key in the map