tweaks to JavaScript code