Started re-factoring code