Moved ALL logic out of app.js into separate module