JS bug fixing