redesign api and add doc