Refactor controller and views