starting to reintegrate the agent code