Refactors main.js