Move variable declaration into function block where variables are being used