Functions and closures in different scopes