refactor, and change api