Added code for agent registration