refactor rest controller