Fixing use of out of scope result variable