updated the main() function to fix issue with the pop() method on agent ids.