refactored app.js + firebase