adjusted code to new api