Restructured and refactored