add a new method that change recursion into circulation which can improve the speed