Re-factored code