optimizing the code I