updated agent to protect against concurrency issues