refactor api module