adapted js for new api