Fix JS bug with timer