re-structuring main.js

still working on the core structure of the main js file