Refactor API