Fixing JS bug