js scope fix