Refactored the js file into being more module-style. - RMUR