some agent refactoring