improved main.js