cleaning up the javascript