fixed javascript code