corrected recursion counter