Optimize the code structure