Refactoring api class