I gather the txt1 stuff is to protect against re-definition of txt, a cheaper way to do this is to wrap the content of the if statement in a (function () { ..... }())