Fixed recursion depth issue