Refactored controller and views