optimizing the code in products page