This is the start of the refactoring of the agent