Refactoring the client api