Refactored code layout