refactor controller and view