refactoring api