code cleanup: js code moved from index.html to .js files