reorganising main.js