added the javascript functionality