move outside function