refactoring to client to api