factory pattern for the client