reworked main.js