refactor api 2