Modified app.js for email undefined checking