Fixed multiple js issues

Removed to `,` separators (can only be used with var declaration)
Moved declaration of `taggedParent` and `nodes` outside the try statement (to fix a out of scope issue)
Added {} to multiline if else statement