added a new function to create the agent