main.js revised