refactor controller