Improving code structure