Refactoring of api