check the depth when add a guard