move logic to app, and render in views