Reworked main.js