insert variable scope fix