enclose some functions in a closure