upgraded main.js