main.js cleaned up