broke the controller logic out of app.js
simplify app logic by using filtering.