Bugfix for nested functions