Move script inside anon function's scope