Fixing JS bug

This should fix #1