refactor some apis