Fix variable out of scope