refactor to support multiple APIs