cleaner code and new api