refactored to use UNIQUE_PREFIX for caching ids