refactor api design