New refactored code