Started re-writing the code to be more modular