Javascript bug fix