variable must be declared at the top of the function for old windows compilers