Fixed javascript bug

Fixes #42.