scripts/main.js
refactoring part 2