simplified code in main.js