Optimized replacing activity IDs with labels