Optimized set queue function