clean up some javascript code