Refactored agent