removed the anon function
Exception handling
working on recursive version