Optimize the code

Optimize the code