apply refactoring in api