I see where your going with this, isn't there any way to do it without putting it in a function? Don't get me wrong it would work just fine but it seems a bit messy to have to create and manage a function for something as simple as a single variable.
A clever person solves a problem. A wise person avoids it. --Einstein