Optimizing code structure