Cleaned up code in main.js