some refactoring in main.js