move to top scope to avoid upvaluing function