Continue to optimize #2, split app.js to make it testable