Modularizing the javascript