controller refactor