Update script to new api