refactoring to client factory
refactoring to client factory