implement api and test