How do I call a function that has a nested function