Refactoring to new api.