variable scope fix