You would wrap this whole thing in a class constructor, instantiate it once (as soon as possible), and then use methods on the class instance to make it do what you want without exposing the value.