Refactored to put more logic in main.js in client/app/main