refactor controller, model and view