Finish refactoring api