completed api refactoring