I am actually stuck with the idea as mentioned in the question, about calling nested functions dynamically.
Say I have 4 functions: fun1(), fun2(), fun3(), fun4()