api refactor