fixed Javascript code