Refactoring

Move logic into controller, not in views