added agent logic