updated app.js logic