refactor the Agent class