refactoring broker & agent