Refactored Code Structure