Issue in scoping of nested functions.