Avoid problems caused by recursive calls

Without this code,when the model is called recursively,it will form an endless loop.