Code re-factoring