Improved code structure