refactor api