Perhaps it was incorrect to use same variable name for both static and local.