refactor API