changed: clean up the javascript code a bit