Loop optimization to generate smart selector grouping and lesser CSS code