correct recursion order