When you instantiate a variable in a function, it's local
only to that function and gets destroyed after leaving the
function. You have it right in the second set of code, but you
don't even need to set them to anything to begin with.
You can put your variable declarations outside of your
function like this: