Re-Factored code