Fixing the discontinue javascript bug