Fix bug in javascript