updated javascript code so that all event listeners have the proper scope
removed unnecessary libraries