Solved a lot of errors and converted to the new api
Updated api