changed code for new api