Restructured main js file to namespace functionality