Code re-factored