Fix JS error - assignment to undeclared variable

- Fixed #19