simplify logic in main.js

closes #98