moved logic to main.js