Refactored app.js to work with mongoDB