Fixing a JS bug