moved client code to lib