Fixing errors in js with scope destroy

Fixing errors in js with scope destroy