some modify to add adhoc agent, code not running right now