improve the main.js to use javascript