Refactoring and simplify API