more client implementation, refactoring