Refectoring Javascript to Modules