candy pattern optimized