updated recursion and exception