Small refactoring in the code of the agent