refactoring accounts controller