made loops instead of hardcoding for agent