added more logic for missing agent tokens