refactor apis