quick edit from like 380 to the end of startAgent