fix javascript for the new api