Refactoring with API