Optimized color algorithm