fix for #294

We want to initialize these variables outside of the for loop.