started refactoring client code