Agent type swtich is added to determine the agent type at the beginning!